package com.guaoran.java8concurrency.before5;

/**
 * @author : guaoran
 * @Description : <br/>
 *  并发编程，java5之前
 * @date :2018/11/24 12:57
 */
public class ThreadMain {
    public static void main(String[] args) throws InterruptedException {
        ChildrenRunnable runnable = new ChildrenRunnable();
        Thread thread = new Thread(runnable,"sub");
        thread.start();
        //等待当前线程执行完毕，串行操作
        //thread.join();

        System.out.printf("[Thread Name :%s]start....\n", Thread.currentThread().getName());
        System.out.printf("[runnable...flag =%s\n", runnable.isFlag());

    }

    private static class ChildrenRunnable implements Runnable{
        private volatile boolean flag = false;
        @Override
        public void run() {
            System.out.printf("[Thread Name :%s]Hello world....\n", Thread.currentThread().getName());
            flag = true;
        }

        public boolean isFlag() {
            return flag;
        }
    }
}
